package ah.file;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

public class DeleteONExitTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			//File file = File.createTempFile("aaa", ".txt", new File("D:/"));
			File file = new File("D:/aaa.txt");//也会删除
			FileOutputStream fos = new FileOutputStream(file);
			fos.write("我是中国人".getBytes());
			fos.close();
			file.deleteOnExit();
			Thread.sleep(10000);
			System.out.println(file.exists());
		} catch (IOException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}
